package model.locations;

import java.util.ArrayList;
import java.util.List;

import exceptions.ThingNotInArea;

import model.things.Thing;


public abstract class Area {
	List<Thing> thingsInArea;
	abstract public String getType();
	protected String description;
	
	public Area(){
		this.thingsInArea = new ArrayList<Thing>();
	}
	//These should be in another class, but for now they are only relevant here
	public void removeThing(String label){
		// We do this until we figure out a better way to remove a single Thing
		// Lists are annoying as poo.
		//if(thingsInArea!=null) thingsInArea.clear();
		for(Thing thing:thingsInArea){
			if(thing.getLabel()==label)
			thingsInArea.remove(label);
		}
	}
	public void addThing(Thing t){
		thingsInArea.add(t);
	}
	public void updateThing(Thing t){
		thingsInArea.remove(t);
		thingsInArea.add(t);
	}
	public void addDescription(String description){
		this.description=description;
	}
	
	public boolean findTypeInVicinity(String type){
		
		if(thingsInArea.size()>0)
		{
			for(Thing thing3:thingsInArea){				
				if(thing3.getType()==type){
					return true;
				}
			}
		}
		return false;
	}
	
	abstract public String getDescription();
	
	abstract public List<Thing> getThingsInVicinity() throws ThingNotInArea;
}
